import { IPSModelSortable } from '../../ipsmodel-sortable';
import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDEField } from '../defield/ipsdefield';
import { IPSDERBase } from '../der/ipsderbase';
import { IPSDEOPPriv } from './ipsdeoppriv';
import { IPSSysUniRes } from '../../security/ipssys-uni-res';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEOPPrivImpl extends PSModelObjectImpl implements IPSDEOPPriv, IPSModelSortable {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get extendMode(): 0 | 2 {
    return this.M.extendMode != null ? this.M.extendMode : 0;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  get mapPSDEName(): string {
    return this.M.mapPSDEName;
  }

  get mapPSDEOPPrivName(): string {
    return this.M.mapPSDEOPPrivName;
  }

  protected mappsder: IPSDERBase | null = null;

  getMapPSDER(): IPSDERBase | null {
    if (this.mappsder != null) return this.mappsder;
    const value = this.M.getMapPSDER;
    if (value == null) {
      return null;
    }
    this.mappsder = this.getMapPSDataEntityMust().findMajorPSDERBase(value);
    return this.mappsder;
  }

  get mapPSDER(): IPSDERBase | null {
    return this.getMapPSDER();
  }

  getMapPSDERMust(): IPSDERBase {
    const value = this.getMapPSDER();
    if (value == null) {
      throw new Error('未指定映射关系对象');
    }
    return value;
  }

  protected mappsdataentity: IPSDataEntity | null = null;

  getMapPSDataEntity(): IPSDataEntity | null {
    if (this.mappsdataentity != null) return this.mappsdataentity;
    const value = this.M.getMapPSDataEntity;
    if (value == null) {
      return null;
    }
    this.mappsdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getMapPSDataEntity') as IPSDataEntity;
    return this.mappsdataentity;
  }

  get mapPSDataEntity(): IPSDataEntity | null {
    return this.getMapPSDataEntity();
  }

  getMapPSDataEntityMust(): IPSDataEntity {
    const value = this.getMapPSDataEntity();
    if (value == null) {
      throw new Error('未指定映射实体对象');
    }
    return value;
  }

  protected mappssysunires: IPSSysUniRes | null = null;

  getMapPSSysUniRes(): IPSSysUniRes | null {
    if (this.mappssysunires != null) return this.mappssysunires;
    const value = this.M.getMapPSSysUniRes;
    if (value == null) {
      return null;
    }
    this.mappssysunires = this.getPSModel4('security.IPSSysUniRes', value, 'getMapPSSysUniRes') as IPSSysUniRes;
    return this.mappssysunires;
  }

  get mapPSSysUniRes(): IPSSysUniRes | null {
    return this.getMapPSSysUniRes();
  }

  getMapPSSysUniResMust(): IPSSysUniRes {
    const value = this.getMapPSSysUniRes();
    if (value == null) {
      throw new Error('未指定系统统一资源');
    }
    return value;
  }

  get mapSysUniResCode(): string {
    return this.M.mapSysUniResCode;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  protected psdefield: IPSDEField | null = null;

  getPSDEField(): IPSDEField | null {
    if (this.psdefield != null) return this.psdefield;
    const value = this.M.getPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdefield = ipsdataentity.findPSDEField(value);
    }
    return this.psdefield;
  }

  get psDEField(): IPSDEField | null {
    return this.getPSDEField();
  }

  getPSDEFieldMust(): IPSDEField {
    const value = this.getPSDEField();
    if (value == null) {
      throw new Error('未指定实体属性');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get dEFieldPriv(): boolean {
    return this.M.dEFieldPriv != null ? this.M.dEFieldPriv : false;
  }

  get mapSysUniRes(): boolean {
    return this.M.mapSysUniRes != null ? this.M.mapSysUniRes : false;
  }

  get systemReserved(): boolean {
    return this.M.systemReserved != null ? this.M.systemReserved : false;
  }

  get cls(): string {
    return 'PSDEOPPrivImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelObject' || cls == 'IPSModelSortable' || cls == 'IPSObject' || cls == 'dataentity.IPSDataEntityObject' || cls == 'dataentity.priv.IPSDEOPPriv') return true;
    return super.instanceof(cls);
  }
}
